package com.five.calendar.ui.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.constraint.solver.Goal;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import com.five.calendar.ApplicationHelper;
import com.five.calendar.R;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by xin on 2017/9/3.
 */

public class GoalAddActivity extends Activity implements View.OnClickListener {
    @BindView(R.id.write_my_own)
    RelativeLayout mCustomItem;
    @BindView(R.id.health)
    RelativeLayout mHealthItem;
    @BindView(R.id.fitness)
    RelativeLayout mFitnessItem;
    @BindView(R.id.hobbies)
    RelativeLayout mHobbiesItem;
    @BindView(R.id.social)
    RelativeLayout mSocialItem;
    @BindView(R.id.efficiency)
    RelativeLayout mEfficiencyItem;
    @BindView(R.id.home)
    RelativeLayout mHomeItem;
    @BindView(R.id.close)
    ImageView mCloseIcon;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_goal_add);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
        }
        ButterKnife.bind(this);
        initView();
    }

    private void initView() {
        mCustomItem.setOnClickListener(this);
        mHealthItem.setOnClickListener(this);
        mFitnessItem.setOnClickListener(this);
        mHobbiesItem.setOnClickListener(this);
        mSocialItem.setOnClickListener(this);
        mEfficiencyItem.setOnClickListener(this);
        mHomeItem.setOnClickListener(this);
        mCloseIcon.setOnClickListener(this);
    }

    public static void startGoalAddActivity(){
        Intent intent = new Intent(ApplicationHelper.getContext(), GoalAddActivity.class);
        ApplicationHelper.getContext().startActivity(intent);
    }

    @Override
    public void onClick(View v) {
        startGoalDetailAddActivity(v.getId());
    }

    private void startGoalDetailAddActivity(int id){
        String type = "";
        switch (id){
            case R.id.write_my_own:
                type="Write my own";
                startGoalDetailAddActivity(type);
                break;
            case R.id.health:
                type = "health";
                startGoalDetailAddActivity(type);
                break;
            case R.id.fitness:
                type = "fitness";
                startGoalDetailAddActivity(type);
                break;
            case R.id.hobbies:
                type = "hobbies";
                startGoalDetailAddActivity(type);
                break;
            case R.id.social:
                type = "social";
                startGoalDetailAddActivity(type);
                break;
            case R.id.efficiency:
                type = "efficiency";
                startGoalDetailAddActivity(type);
                break;
            case R.id.home:
                type = "home";
                startGoalDetailAddActivity(type);
                break;
            case R.id.close:
                finish();
                break;
        }

    }

    private void startGoalDetailAddActivity(String type){
        Intent intent = new Intent();
        intent.putExtra("type", type);
        intent.setClass(GoalAddActivity.this, GoalDetailAddActivity.class);
        startActivity(intent);
    }
}
